function gS = linearGradient(A, X)

% d (A*X) / d X

[N D] = size(X);

gS = zeros(size(A, 1), D, N, D);
for i = 1:size(A, 1)
    for j = 1:D
        gS(i, j, :, j) = gS(i, j, :, j) + reshape(A(i, :), [1 1 N]);
    end
end
